package com.yjz.log.manager;

import androidx.annotation.NonNull;

import com.yjz.log.config.JLogConfig;
import com.yjz.log.print.ILogPrinter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 作用 : log管理工具
 * 作者 : yjz
 * 时间 : 2024/9/14 08:56
 */
public class JLogManager {
    private static JLogManager instance;
    private final JLogConfig jLogConfig;
    private final List<ILogPrinter> printers = new ArrayList<>();

    public JLogManager(JLogConfig jLogConfig, ILogPrinter[] printers) {
        this.jLogConfig = jLogConfig;
        this.printers.addAll(Arrays.asList(printers));
    }

    public static JLogManager getInstance() {
        return instance;
    }

    public static void init(@NonNull JLogConfig logConfig, ILogPrinter... printers) {
        instance = new JLogManager(logConfig, printers);
    }

    public JLogConfig getConfig() {
        return jLogConfig;
    }

    public List<ILogPrinter> getPrinters() {
        return printers;
    }

    public void addPrinter(ILogPrinter printer) {
        printers.add(printer);
    }

    public void removePrinter(ILogPrinter printer) {
        printers.remove(printer);
    }
}
